package com.kevin.collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class CollectionTest {
    public static void main(String[] args) {
        Collection<String> collection = new ArrayList<>();
        ((ArrayList<String>) collection).add("abc");
        ((ArrayList<String>) collection).add("def");
        collection.forEach(obj-> System.out.println(obj));
        Iterator<String> iterator = collection.iterator();
        while(iterator.hasNext()){
            System.out.println(iterator.next());
            if (collection.contains("abc")){
                collection.remove("abc");
            }
        }
        System.out.println(collection);
    }
}
